home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / ear / mui23dev.lha / MUI / Developer / C / Examples / BoopsiDoor.c < prev    next >
C/C++ Source or Header  |  1994-12-23  |  3KB  |  123 lines

  1. /*
  2. ** This program needs at least V39 include files !
  3. */
  4.  
  5. #include "demo.h"
  6.  
  7. #include "gadgets/colorwheel.h"
  8. #include "intuition/icclass.h"
  9. #include "intuition/gadgetclass.h"
  10.  
  11.  
  12. /*
  13. ** Gauge object macro to display colorwheels
  14. ** hue and saturation values.
  15. */
  16.  
  17. #define InfoGauge GaugeObject,\
  18.     GaugeFrame    , \
  19.     MUIA_Background  , MUII_BACKGROUND,\
  20.     MUIA_Gauge_Max   , 16384,\
  21.     MUIA_Gauge_Divide, 262144,\
  22.     MUIA_Gauge_Horiz , TRUE,\
  23.     End
  24.  
  25.  
  26. int main(int argc,char *argv[])
  27. {
  28.     struct Library *ColorWheelBase;
  29.     APTR App,Window,Wheel,Hue,Sat;
  30.     LONG signal;
  31.  
  32.     init();
  33.  
  34.     if (!(ColorWheelBase = OpenLibrary("gadgets/colorwheel.gadget",0)))
  35.         fail(NULL,"colorwheel boopsi gadget not available\n");
  36.  
  37.     App = ApplicationObject,
  38.         MUIA_Application_Title      , "BoopsiDoor",
  39.         MUIA_Application_Version    , "$VER: BoopsiDoor 10.11 (23.12.94)",
  40.         MUIA_Application_Copyright  , "©1992/93, Stefan Stuntz",
  41.         MUIA_Application_Author     , "Stefan Stuntz",
  42.         MUIA_Application_Description, "Show a boopsi colorwheel with MUI.",
  43.         MUIA_Application_Base       , "BOOPSIDOOR",
  44.  
  45.         SubWindow, Window = WindowObject,
  46.             MUIA_Window_Title, "BoopsiDoor",
  47.             MUIA_Window_ID   , MAKE_ID('B','O','O','P'),
  48.  
  49.             WindowContents, VGroup,
  50.  
  51.                 Child, ColGroup(2),
  52.                     Child, Label("Hue:"       ), Child, Hue = InfoGauge,
  53.                     Child, Label("Saturation:"), Child, Sat = InfoGauge,
  54.                     Child, RectangleObject,MUIA_Weight,0,End, Child, ScaleObject, End,
  55.                     End,
  56.  
  57.                 Child, Wheel = BoopsiObject,  /* MUI and Boopsi tags mixed */
  58.  
  59.                     GroupFrame,
  60.  
  61.                     MUIA_Boopsi_ClassID  , "colorwheel.gadget",
  62.  
  63.                     MUIA_Boopsi_MinWidth , 30, /* boopsi objects don't know */
  64.                     MUIA_Boopsi_MinHeight, 30, /* their sizes, so we help   */
  65.  
  66.                     MUIA_Boopsi_Remember , WHEEL_Saturation, /* keep important values */
  67.                     MUIA_Boopsi_Remember , WHEEL_Hue,        /* during window resize  */
  68.  
  69.                     MUIA_Boopsi_TagScreen, WHEEL_Screen, /* this magic fills in */
  70.                     WHEEL_Screen         , NULL,         /* the screen pointer  */
  71.  
  72.                     GA_Left     , 0,
  73.                     GA_Top      , 0, /* MUI will automatically     */
  74.                     GA_Width    , 0, /* fill in the correct values */
  75.                     GA_Height   , 0,
  76.  
  77.                     ICA_TARGET  , ICTARGET_IDCMP, /* needed for notification */
  78.  
  79.                     WHEEL_Saturation, 0, /* start in the center */
  80.  
  81.                     End,
  82.                 End,
  83.             End,
  84.         End;
  85.  
  86.     if (!App)
  87.     {
  88.         if (ColorWheelBase) CloseLibrary(ColorWheelBase);
  89.         fail(App,"Failed to create Application.");
  90.     }
  91.  
  92.  
  93. /*
  94. ** you can react on every boopsi notification
  95. ** event as on any other MUI attribute.
  96. */
  97.  
  98.     DoMethod(Wheel,MUIM_Notify,WHEEL_Hue       ,MUIV_EveryTime,Hue,4,MUIM_Set,MUIA_Gauge_Current,MUIV_TriggerValue);
  99.     DoMethod(Wheel,MUIM_Notify,WHEEL_Saturation,MUIV_EveryTime,Sat,4,MUIM_Set,MUIA_Gauge_Current,MUIV_TriggerValue);
  100.  
  101.  
  102. /*
  103. ** Simplest possible MUI main loop.
  104. */
  105.  
  106.     DoMethod(Window,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,App,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  107.     set(Window,MUIA_Window_Open,TRUE);
  108.  
  109.     while (DoMethod(App,MUIM_Application_Input,&signal) != MUIV_Application_ReturnID_Quit)
  110.         if (signal)
  111.             Wait(signal);
  112.  
  113.     set(Window,MUIA_Window_Open,FALSE);
  114.  
  115.  
  116. /*
  117. ** shut down.
  118. */
  119.  
  120.     if (ColorWheelBase) CloseLibrary(ColorWheelBase);
  121.     fail(App,NULL);
  122. }
  123.